(function () {
    "use strict";

    angular.module('core').factory('arquivoService', factory);
    factory.$inject = ['$http', '$q'];

    function factory($http, $q) {

        return {
            get: function (id) {
                var deferred = $q.defer();
                $http.post('/arquivo/get', id)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            getAll: function (args) {
                var deferred = $q.defer();
                $http.post('/arquivo/getall', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            count: function (args) {
                var deferred = $q.defer();
                $http.post('/arquivo/count', args)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },

            getContentBase64: function (id) {
                var deferred = $q.defer();
                $http.post('/arquivo/getContentBase64', id)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            
            save: function (item) {
                var deferred = $q.defer();
                $http.post('/arquivo/save', item)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
            delete: function (id) {
                var deferred = $q.defer();
                $http.post('/arquivo/delete', id)
                    .success(function (data) { deferred.resolve(data); })
                    .error(function (data, status, headers, config) { deferred.reject(data); });
                return deferred.promise;
            },
        };
    }

})();


